﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once

#include "GcmpModel.h"
#include "IEndOfTransactionProcessor.h"

namespace gcmp
{
    class IDocument;

    /// \brief 自定义事务结束时处理器接口
    ///
    /// 实现自定义事务结束处理器后， 可使用以下两个接口将处理器注册到平台中
    ///     在事务结束，更新文档前触发（Process）：UserTransactionUtils::AddEndofProcessorBeforeRegenerateAll
    ///     在事务结束，更新文档后触发（Process）：UserTransactionUtils::AddEndofProcessorAfterRegenerateAll
    class GCMP_MODEL_EXPORT IEndOfTransactionProcessorWithChangedElements :public gcmp::IEndOfTransactionProcessor
    {
        DEFINE_CAST_DERIVED(gcmp::IEndOfTransactionProcessorWithChangedElements, gcmp::IEndOfTransactionProcessor)
    public:
        /// \brief 结束事务时的自定义操作入口,并且附加有本次transaction中发生增删改elementsId
        ///
        /// \param pDoc 文档指针
        virtual void ProcessWithChangedElements(
            IDocument* pDoc,
            const std::vector<ElementId>& added,
            const std::vector<ElementId>& deleted,
            const std::vector<ElementId>& updated
        ) = 0;

        /// \brief 析构函数
        virtual ~IEndOfTransactionProcessorWithChangedElements() {}
    };
}